﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using InfraTools.Class;


namespace InfraTools
{
    public class Computers : GlpiComputer
    {
        public bool Sel { get; set; }
        public string Mac { get; set; }
        public string Sccm_Collection { get; set; }
        public bool PC_Label { get; set; }
        

        public Computers()
        {
            
        }

        public Computers(string hostname, string mac, string sccm_collection, bool pc_label, string status)
        {
            name = hostname;
            Mac = mac;
            Sccm_Collection = sccm_collection;
            PC_Label = pc_label;
            states_id = status; 
        }

        public void GetInfrafields()
        {
            if (otherserial.Contains(',')) 
            {
                string[] othser = otherserial.Split(',');
                Sel = bool.Parse(othser[0]);
                Mac = othser[1];
                Sccm_Collection = othser[2];
                PC_Label = bool.Parse(othser[3]);
            }
        }

        public void SetInfrafields()
        {


            StringBuilder builder = new StringBuilder();
            builder.Append(Sel.ToString());
            builder.Append(',');
            builder.Append(Mac);
            builder.Append(',');
            builder.Append(Sccm_Collection);
            builder.Append(',');
            builder.Append(PC_Label.ToString());
            otherserial = builder.ToString();
            
        }

        public GlpiComputer GetGlpiComputer()
        {
            SetInfrafields();
            GlpiComputer pc = new GlpiComputer();
            pc.autoupdatesystems_id = autoupdatesystems_id;
            pc.autoupdatesystems_name = autoupdatesystems_name;
            pc.comment = comment;
            pc.computermodels_id = computermodels_id;
            pc.computermodels_name = computermodels_name;
            pc.computertypes_id = computertypes_id;
            pc.computertypes_name = computertypes_name;
            pc.contact = contact;
            pc.Contract = Contract;
            pc.date_mod = date_mod;
            pc.domains_id = domains_id;
            pc.domains_name = domains_name;
            pc.entities_id = entities_id;
            pc.entities_name = entities_name;
            pc.groups_id = groups_id;
            pc.groups_id_tech = groups_id_tech;
            pc.id = id;
            pc.is_ocs_import = is_ocs_import;
            pc.is_ocs_import_name = is_ocs_import_name;
            pc.locations_id = locations_id;
            pc.manufacturers_id = manufacturers_id;
            pc.manufacturers_name = manufacturers_name;
            pc.name = name;
            pc.name_name = name_name;
            pc.networks_id = networks_id;
            pc.operatingsystems_id = operatingsystems_id;
            pc.operatingsystems_name = operatingsystems_name;
            pc.operatingsystemservicepacks_id = operatingsystemservicepacks_id;
            pc.operatingsystemservicepacks_name = operatingsystemservicepacks_name;
            pc.operatingsystemversions_id = operatingsystemversions_id;
            pc.operatingsystemversions_name = operatingsystemversions_name;
            pc.os_license_number = os_license_number;
            pc.os_licenseid = os_licenseid;
            pc.otherserial = otherserial;
            pc.serial = serial;
            pc.states_id = states_id;
            pc.states_name = states_name;
            pc.users_id = users_id;
            pc.users_id_tech = users_id_tech;
            pc.users_name = users_name;
            pc.uuid = uuid;

            return pc;
        
        }


        public void  setGlpiComputer(GlpiComputer pc)
        {
            autoupdatesystems_id = pc.autoupdatesystems_id ;
            autoupdatesystems_name = pc.autoupdatesystems_name ;
            comment = pc.comment ;
            computermodels_id = pc.computermodels_id ;
            computermodels_name = pc.computermodels_name ;
            computertypes_id = pc.computertypes_id ;
            computertypes_name = pc.computertypes_name;
            contact = pc.contact ;
            Contract = pc.Contract ;
            date_mod = pc.date_mod ;
            domains_id = pc.domains_id ;
            domains_name = pc.domains_name ;
            entities_id = pc.entities_id  ;
            entities_name = pc.entities_name  ;
            groups_id = pc.groups_id  ;
            groups_id_tech = pc.groups_id_tech  ;
            id = pc.id ;
            is_ocs_import = pc.is_ocs_import;
            is_ocs_import_name = pc.is_ocs_import_name;
            locations_id = pc.locations_id;
            manufacturers_id = pc.manufacturers_id;
            manufacturers_name = pc.manufacturers_name ;
            name = pc.name;
            name_name = pc.name_name;
            networks_id = pc.networks_id;
            operatingsystems_id = pc.operatingsystems_id;
            operatingsystems_name = pc.operatingsystems_name;
            operatingsystemservicepacks_id = pc.operatingsystemservicepacks_id;
            operatingsystemservicepacks_name = pc.operatingsystemservicepacks_name;
            operatingsystemversions_id = pc.operatingsystemversions_id ;
            operatingsystemversions_name = pc.operatingsystemversions_name ;
            os_license_number = pc.os_license_number;
            os_licenseid = pc.os_licenseid;
            otherserial = pc.otherserial;
            serial = pc.serial;
            states_id = pc.states_id;
            states_name = pc.states_name;
            users_id = pc.users_id;
            users_id_tech = pc.users_id_tech;
            users_name = pc.users_name;
            uuid = pc.uuid;
            GetInfrafields();
        }
        
    
    }

}
